package com.itheima.homework03;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 6666);
        OutputStream out = socket.getOutputStream();
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("d:/test/t.txt"));
        byte[] buf = new byte[1024];
        int len = -1;
        while ((len = bis.read(buf)) != -1) {
            out.write(buf, 0, len);
        }
        socket.shutdownOutput();
        System.out.println(out);

        InputStream is = socket.getInputStream();
        len = is.read(buf);
        System.out.println(new String(buf,0,len));
        socket.close();
        bis.close();

    }
}
